//
//  AXFAddproductView.m
//  aixinfeng005
//
//  Created by apple on 2016/10/11.
//  Copyright © 2016年 BBSWaitting. All rights reserved.
//

#import "AXFAddproductView.h"

@interface AXFAddproductView ()
/**
 减号按钮
 */
@property (nonatomic, weak) IBOutlet UIButton *decreaseBtn;

/**
 数量
 */
@property (nonatomic, weak) IBOutlet UILabel *countLbl;
@end

@implementation AXFAddproductView



+ (instancetype)makeView
{
    return [[NSBundle mainBundle] loadNibNamed:@"AXFAddproductView" owner:nil options:nil].lastObject;
}

- (void)awakeFromNib {
    
    self.count = 0;
}
- (IBAction)increaseBtnClick:(UIButton *)sender
{
    self.count++;
    
    _isIncrease = YES;
    
    // 1.应用程序主窗口! [UIApplication sharedApplication] 获取应用程序对象,单例!
    UIWindow *keyW = [UIApplication sharedApplication].keyWindow;
    
    // 2.转换坐标-> 将按钮的center 转为 相对于应用程序主窗口的点!
    _startPoint = [self convertPoint:sender.center toView:keyW];
    
    self.cellBlock(_startPoint);
}

- (IBAction)decreaseBtnClick:(UIButton *)sender
{
    self.count--;
    
    _isIncrease = NO;

    

}


#pragma mark - 重写set方法
- (void)setCount:(NSInteger)count {
    
    _count = count;
    
    if (count == 0) {
        
        _decreaseBtn.hidden = YES;
        _countLbl.hidden = YES;
    } else {
        
        _decreaseBtn.hidden = NO;
        _countLbl.hidden = NO;
        
    }
    
    // 设置数量信息
    _countLbl.text = @(count).description;
    
}

@end
